<template>
	<z-paging ref="paging" :auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false"
		v-model="dataList" @query="queryList" :default-page-size='pageSizeCount' :default-page-no='0'>
		
		<view class="flex-row" style="flex-wrap: wrap; padding: 10px;">
			<view @click="clickItem(index)" v-for="(item,index) in dataList" :key="index">
				<ImageCell :dataModel='item'></ImageCell>
			</view>
		</view>

	</z-paging>
</template>

<script>
	import ZSSwiper from '../../components/zs-swiper/zs-swiper.vue'
	import ImageCell from '../../components/gif-image-cell/gif-image-cell.vue'

	export default {
		components: {
			ZSSwiper,
			ImageCell
		},
		data() {
			return {
				dataList: [],

				pageSizeCount: 20,
				pageNo: 0,
			}
		},
		methods: {
			click(name) {
				this.$refs.uToast.success(`点击了第${name}个`)
			},
			queryList(pageNo, pageSize) {
				this.pageNo = pageNo;
				console.log('页面参数===pageNo=', pageNo, 'pageSize=', pageSize)
				this.$uniCloudApi.get_data_list(3, '推荐', pageNo, pageSize).then((res) => {
					this.$refs.paging.complete(res);
				}).catch(err => {
					this.$refs.paging.complete([]);
					this.errStr = err.toString();
					uni.showToast({
						title: err.toString(),
						icon: 'none'
					})
				})
			},
			clickItem(index) {
				var item = this.dataList[index]
				var type = this.typeValue
				var model = {
					'imageUrl': item.imageUrl,
					'tableType': 3,
					'type': type,
					"pageSizeCount": this.pageSizeCount,
					'pageNo': this.pageNo
				}
				uni.navigateTo({
					url: '../details-page/details-page?model=' + this.$encodeJson(model)
				});
			}
		}
	}
</script>

<style lang="scss">

</style>